package com.wangzh.lang;

import java.util.Scanner;

public class StringDemo {
    public static void main(String[] args) {
        String rightUsername = "zhangsan";
        String rightPassword = "123456";

        Scanner in = new Scanner(System.in);


        for (int i = 0; i < 3; i++) {
            System.out.println("请输入用户名");
            String username = in.next();
            System.out.println("请输入密码");
            String password = in.next();

            if (username.equals(rightUsername) && password.equals(rightPassword)) {
                System.out.println("用户登录成功");
                break;
            }else {
                System.out.println("用户登录失败，用户名或密码有误，您还剩余"+(2-i)+"次机会");
            }
        }
    }
}
